using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace tutors_clus.Models.Mapping
{
    public class courseMap : EntityTypeConfiguration<course>
    {
        public courseMap()
        {
            // Primary Key
            this.HasKey(t => t.id_cou);

            // Properties
            this.Property(t => t.name_cou)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("course");
            this.Property(t => t.id_cou).HasColumnName("id_cou");
            this.Property(t => t.name_cou).HasColumnName("name_cou");
            this.Property(t => t.id_tea).HasColumnName("id_tea");
            this.Property(t => t.limited_num).HasColumnName("limited_num");
            this.Property(t => t.registered_num).HasColumnName("registered_num");
            this.Property(t => t.createdate_cou).HasColumnName("createdate_cou");
            this.Property(t => t.startdate_cou).HasColumnName("startdate_cou");
            this.Property(t => t.enddate_cou).HasColumnName("enddate_cou");
            this.Property(t => t.status_cou).HasColumnName("status_cou");
            this.Property(t => t.decription_cou).HasColumnName("decription_cou");

            // Relationships
            this.HasOptional(t => t.teacher)
                .WithMany(t => t.courses)
                .HasForeignKey(d => d.id_tea);

        }
    }
}
